import Vue from 'vue';
import Router from 'vue-router';
import Hello from 'components/Hello';
import Test from 'components/Test';
import Home from 'containers/Home';
Vue.use(Router);
const router = new Router({
    routes: [
        // 所有根路径都跳转到首页
        {
            path: '/',
            redirect: '/home',
        },
        {
            path: '/test',
            name: 'Test',
            component: Test
        },
        {
            path: '/home',
            name: 'home',
            component: Home
        },
        // 所有未知路径都跳转至首页
        {
            path: '*',
            redirect: '/home',
        }
    ]
});
// 在路由跳转之前可以重定向
// router.beforeEach((to,from,next)=>{
//   console.log(to,from);
//   if(to.path!=='/' && to.path!=='/home') {
//     next('/home');
//   } else {
//     next();
//   }
// });
export default router;